<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	
	
	<script src="/site_media/js/jquery-1.5.min.js" type="text/javascript"></script> 
	   
	
	<script type="text/javascript"> 
	$(function() {
        
	    $("#bn").click(function(){
	        var $scripttext = $("#userscript");
	        var stockid = $("#instockid").val()
	        
	        //alert(stockid);
    	    //alert($scripttext.val());
    	    ///+"&"+"stockid="+ stockid + "&" + "sdate=20110101" +"&" + "edate=20110303"
    	      $.ajax({
	            url: "/test4/",
			    type: "POST",
    			data: "script="+encodeURIComponent($scripttext.val().toString())+"&"+"stockid="+ stockid,
    			
			    success: function( data ) {
			        alert(data);
		        },
		        error: function(data){
		            alert("post data error");
		        }
		    });
	     });
	     
	    
	});
	</script> 
	
	<title>stest</title>
</head>
<body>
    <form method='post' action='/test4/'> {% csrf_token %}
	       <textarea rows='10' cols='60' name='userscript' id='userscript'>
	       </textarea>
    	   <input type='text'  name="stockid" id="instockid" />
	       <input type='button' id='bn' value='sb' />
	       <input type='submit' id='Button1' value='submit' />
    </form>
    
</body>
</html>